<template>
    <m-card
        class="m-notice-bar"
        @click="goto"
        card-content-style=" display: flex;flex-direction: row;align-items: stretch;"
    >
        <view class="m-notice-bar-img-box">
            <image v-if="image" :src="imageUrl" :draggable="false" class="m-notice-bar-img" />
        </view>
        <uni-notice-bar
            scrollable
            show-get-more
            :text="text"
            :show-icon="showIcon"
            class="m-notice-bar-text"
            color="black"
            background-color="white"
            moreColor="black"
            :speed="60"
        />
    </m-card>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import MCard from '@/components/common/MCard.vue'
const props = defineProps({
    text: { type: String, required: true, default: '' },
    image: { type: String },
    pageUrl: { type: String },
    showIcon: { type: Boolean, default: false }
})
const imageUrl = computed<string>(() => {
    let url: URL = new URL(props.image || '')
    return url.href
})
const goto = function () {}
</script>

<style lang="scss" scoped>
.m-notice-bar-img-box {
    background-color: $uni-bg-color;
    margin-bottom: 20rpx;
    line-height: 60rpx;
    padding-left: 10rpx;
    margin: 0rpx;
    .m-notice-bar-img {
        height: 42rpx;
        width: 200rpx;
        background-color: $uni-bg-color;
        vertical-align: middle;
    }
}
.m-notice-bar-text {
    margin: 0rpx;
    padding: 10rpx;
}
</style>
